package cn.kuick.match.test2;

public class Test2 {

	public static class LuomaConvert {
		private int num;
		private String[][] result;
		
		public LuomaConvert(int num) {
			this.num = num;
			this.result = new String[num][num];
			
			for (int i=0; i<result.length; i++) {
				String[] dd = result[i];
				
				for (int j=0; j<dd.length; j++) {
					dd[j] = " ";
				}
			}
		}	
		
		public void cal() {
			int total = this.num * this.num;
			
			int num = 0;
			int x = 0;
			int y = 0;
			
			try {
				for(int i=1; i<= total; i++ ) {
					this.result[x][y] = "" + i;
					
					if (x == 0) {
						x = (++num);
						y = 0;
					} else {
						y += 1;
						x -= 1;
					}
				}
			} catch(Exception e) {}
		}
		
		public void print() {
			for (int i=0; i<result.length; i++) {
				String[] dd = result[i];
				
				for (int j=0; j<dd.length; j++) {
					
					if (j == dd.length -1) {
						System.out.print(dd[j]);
					} else {
						System.out.print(dd[j] + " ");
					}
				}
				
				System.out.println();
			}
			
			System.out.println();
		}
	}
	
	public static void convert(int num) {
		LuomaConvert convert = new LuomaConvert(num);
		convert.cal();
		convert.print();
	}
	
	public static void main(String[] args) {
		convert(6);
	}
}
